﻿
@{
    Layout = null;
}

<div class="w_withdraw" ng-controller="MemberRechargeController" >
    <div class="w_withTop">
        <div class="w_withTop_ti">充值金额</div>
        <p class="w_withTop_con">
            <span></span>
            <input type="number" placeholder="请输入充值金额" ng-model="money" />
        </p>
    </div>
    <div class="w_czsub" ng-click="recharge()"><a>充值</a></div>
    <div class="w_cz_a"><img src="/Content/images/w_58.png" /></div>
    @*<div class="w_cz_a"><img src="/Content/images/w_59.png" /></div>*@
    <div class="w_cz_b">
        <div class="w_cz_bcon">
            <p ng-repeat="item in Level">{{item.LevelName}}：{{item.Explain}}</p>
        </div>
    </div>
</div>
<script>
    App.controller('MemberRechargeController', [
            '$scope', '$state', '$route', '$rootScope', '$http',
                function ($scope, $state, $route, $rootScope, $http) {
                    $scope.Level = [];
                    $http.post("/UserCenter/GetMemberLevel").then(function (response) {
                        if (response.data.isSuccess) {
                            $scope.Level = angular.copy(response.data.data);
                        }

                    });
                    var tt = function () {
                        $rootScope.WxShare($rootScope.pageTitle(), '优品三悦', location.href, $rootScope.LogoUrl);
                    }

                    setTimeout(tt, 1000)
                    $scope.recharge = function ()
                    {
                        if ($scope.money == undefined || $scope.money == "" || $scope.money <= 0)
                        {
                            layer.msg("请输入充值金额");
                            return;
                        }
                        layer.load(2);
                        $http.post("/UserCenter/ToRecharge", { money: $scope.money }).then(function (response) {
                            layer.closeAll('loading');
                            if (response.data.isSuccess) {
                                var id = response.data.data;
                                //$state.go('shop.recharge', {id:id});
                                window.location.href = "/OrderPayment/Recharge?id=" + id;
                            }
                            else {
                                layer.msg(response.data.msg);
                            }
                        });
                    }
                }
    ]);
</script>